<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title> - 数据表格</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico"> <link href="css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="css/font-awesome.css?v=4.4.0" rel="stylesheet">

    <!-- Data Tables -->
    <link href="css/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet">

    <link href="css/animate.css" rel="stylesheet">
    <link href="css/style.css?v=4.1.0" rel="stylesheet">
    <style>
        th ,td{
            text-align: center;
            width:278px;
        }
        #layer-date{
            position: absolute;
            left:100px;
            top:60px;
            z-index: 1000;
            padding: 0;
            margin-left: 200px;
            margin-top: -5px;
            margin-bottom: -31px;
            border: 0;
            width: 550px;
            float: left;
        }
    </style>

</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">

                        <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal6">
                            添加客服
                        </button>
                    </div>
                    <div class="ibox-content">

                        <table class="table table-striped table-bordered table-hover dataTables-example">
                            <thead>
                            <tr>
                                <th style="">ID</th>
                                <th>客服名称</th>
                                <th>客服qq</th>
                                <th>在线状态</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php if(!empty($data)): ?>
                                <?php foreach($data as $key=>$value): ?>
                                    <tr class="gradeX">
                                        <td style=""><?php echo e($key+1); ?></td>
                                        <td><?php echo e($value['username']); ?></td>
                                        <td><?php echo e($value['qq']); ?></td>
                                        <td><?php echo e($value['status']==1 ? '在线':'下线'); ?></td>
                                        <td>
                                            <?php if($value['status']==1): ?>
                                            <button  class="btn btn-success online" data-status=0 data-id=<?php echo e($value['id']); ?>  >下线</button>
                                             <?php else: ?>
                                                <button class="btn btn-success off-line"  data-status = 1 data-id=<?php echo e($value['id']); ?> >上线</button>
                                            <?php endif; ?>
                                                <button  class="btn btn-primary onlineTeam-redact" data-toggle="modal" data-target="#redact"  data-id=<?php echo e($value['id']); ?>  data-name=<?php echo e($value['username']); ?>  data-qq=<?php echo e($value['qq']); ?> >编辑</button>
                                                <button   class="btn btn-danger onlineTeam-delete"   data-id=<?php echo e($value['id']); ?>  data-name=<?php echo e($value['username']); ?>  data-qq=<?php echo e($value['qq']); ?> >删除</button>
                                        </td>
                                    </tr>
                                <?php endforeach; ?>
                            </tbody>
                            <?php else: ?>
                                <tfoot>
                                <tr>
                                    <th colspan="5">还没有任何信息哦！</th>
                                </tr>
                                </tfoot>
                            <?php endif; ?>
                        </table>
                    </div>
                    <div class="modal inmodal fade" id="redact" tabindex="-1" role="dialog"  aria-hidden="true">
                        <div class="modal-dialog modal-sm">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                                    <h4 class="modal-title">修改客服信息</h4>
                                </div>
                                <div class="modal-body">
                                    <form action="">
                                        <div class="input-group">
                                            <span style="float: left;margin-top: 4px;font-size: 14px;">名称：</span>
                                            <input type="text" id="kefu-username" style="width: 190px;"  autocomplete="new-password" name=kefu_username" class="form-control" value="">
                                        </div>
                                        <?php /*<input type="text" class="form-control"  name="username" value="">*/ ?>

                                        <div class="input-group">
                                            <span style="float: left;margin-top: 17px;font-size: 14px;margin-right: 9px;">qq：&nbsp;</span>
                                            <input type="text" id="kefu-qq" style="width: 190px;margin-top: 15px;"   autocomplete="new-password" id="" name="kefu_qq" class="form-control" value="">
                                        </div>

                                        <input type="hidden" id="kefu-id" name="kefu_id" value="">
                                    </form>
                                </div>
                                <div class="modal-footer">
                                    <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                                    <button type="button" id="onlineTeam-save" class="btn btn-primary">保存</button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>


<div class="modal inmodal fade" id="myModal6" tabindex="-1" role="dialog"  aria-hidden="true">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title">添加客服</h4>
            </div>
            <div class="modal-body">
                <form action="/onlineTeamAdd" method="post">
                    <div class="input-group">
                        <span style="float: left;margin-top: 4px;font-size: 14px;">名称：</span>
                        <input type="text"  style="width: 190px;" name="username"  autocomplete="new-password"  class="form-control" value="">
                    </div>
                    <div class="input-group">
                        <span style="float: left;margin-top: 17px;font-size: 14px;margin-right: 9px;">qq：&nbsp;</span>
                        <input type="text" id="add-qq" style="width: 190px;margin-top: 15px;"  name="qq"  autocomplete="new-password" class="form-control" value="">
                    </div>
                   <?php echo csrf_field(); ?>

                    <div class="modal-footer">
                        <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                        <?php /*<button type="button" id="onlineTeam-add" class="btn btn-primary">保存</button>*/ ?>
                        <button type="submit" id="onlineTeam-add" class="btn btn-primary">保存</button>
                    </div>
                </form>
            </div>

        </div>
    </div>
</div>

<!-- 全局js -->
<script src="/js/jquery.min.js?v=2.1.4"></script>
<script src="/js/bootstrap.min.js?v=3.3.6"></script>



<script src="/js/plugins/jeditable/jquery.jeditable.js"></script>

<!-- Data Tables -->
<script src="/js/plugins/dataTables/jquery.dataTables.js"></script>
<script src="/js/plugins/dataTables/dataTables.bootstrap.js"></script>

<!-- 自定义js -->
<?php /*<script src="/js/content.js?v=1.0.0"></script>*/ ?>
<script src="/js/onlineteam.js"></script>


<script src="js/plugins/layer/laydate/laydate.js"></script>

<!-- Page-Level Scripts -->
<script>

    $(function(){
        $('.online').click(function(){
            var id = $(this).attr('data-id');
            var status = $(this).attr('data-status');
            $.ajax({
                url: '/onlineteamupdatestatus',
                type: 'get',
                data: {
                    id: id,
                    status: status
                },
                timeout: 5000,
                dataType: 'json',
                success: function (data, textStatus, jqXHR) {
                    if (data.error_code == 0) {
                        self.location='/onlineteam';
                        alert('客服已下线');
                        }
                    },
                error: function (xhr, textStatus) {
                    alert('失败！');
                }
            })

        });
    });

    $(function(){
        $('.off-line').click(function(){
            var id = $(this).attr('data-id');
            var status = $(this).attr('data-status');
            $.ajax({
                url: '/onlineteamupdatestatus',
                type: 'get',
                data: {
                    id: id,
                    status: status
                },
                timeout: 5000,
                dataType: 'json',
                success: function (data, textStatus, jqXHR) {
                    if (data.error_code == 0) {
                        self.location='/onlineteam';
                        alert('客服已上线');
                    }
                },
                error: function (xhr, textStatus) {
                    alert('失败！');
                }
            })

        });
    });







    $(document).ready(function () {
        $('.dataTables-example').dataTable();

        /* Init DataTables */
        var oTable = $('#editable').dataTable();

        /* Apply the jEditable handlers to the table */
        oTable.$('td').editable('../example_ajax.php', {
            "callback": function (sValue, y) {
                var aPos = oTable.fnGetPosition(this);
                oTable.fnUpdate(sValue, aPos[0], aPos[1]);
            },
            "submitdata": function (value, settings) {
                return {
                    "row_id": this.parentNode.getAttribute('id'),
                    "column": oTable.fnGetPosition(this)[2]
                };
            },

            "width": "90%",
            "height": "100%"
        });


    });

    function fnClickAddRow() {
        $('#editable').dataTable().fnAddData([
            "Custom row",
            "New row",
            "New row",
            "New row",
            "New row"]);

    }
</script>




</body>

</html>
